package Frame.shopSet;

import FCRendering.FCRBattleOrderConstant;
import FCRendering.FCRMaster;
import FCRendering.sw.FCRValues;
import Frame.entity.UnifyShopSayUIEntity;
import Function.FCMutilPlayCache;
import VWorldGameStudio.FCPlayerInfo;
import VWorldGameStudio.FCRPlayerLink;
import VWorldGameStudio.events.BattleEvent;
import lombok.Setter;
import socket.FCRSocketClient;
import socket.FCRSocketServer;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import static FCRendering.FCRMaster.*;

//怪物战斗测试
public class FunctionMonsterTest extends AShopFuntion {
    private Vector<String> monsters = new Vector<>();

    private int showFristIndex = 0;
    @Setter
    private int endI = 0;

    public FunctionMonsterTest() {
        buildShopWindow();
    }

    public void buildShopWindow() {
        monsters.clear();
        monsters.addAll(monLib.monstername);
        setEndI(Math.min(monsters.size(), showFristIndex + 7));
        resetUI();
    }

    private void resetUI() {
        FCRValues.resetUnifySayUIEntity();
        int m = 0;
        for (int i = showFristIndex; i < endI; i++) {
            FCRValues.leftWindowUI[m].leftText = monLib.getMonsterOfID(monsters.get(i)).getChName();
            m++;
        }
        FCRValues.rightWindowUI[4].rightText = "上一页";
        FCRValues.rightWindowUI[5].rightText = "下一页";
        FCRValues.rightWindowUI[6].rightText = "退出";
    }

    @Override
    public void clickLeftWindow(int i, UnifyShopSayUIEntity entity) {
        if (entity.leftText.length() > 1) {
           String mos = monsters.get(showFristIndex + i);
           //TODO
            BattleEvent battleEvent = new BattleEvent("battle", String.valueOf(System.currentTimeMillis()));
            battleEvent.getMonsterId().add(mos);
            fcv.setBattleEvent(battleEvent);
            fcv.setBattleRounds(1);
            fcv.setMonsterBuilding(true);
            fcv.setOldMusicNum(sound.getNowMusicNum());
            sound.setBackgroundMusic(8);
            fcv.setOpenSay(false);
            fcv.setSayText(null);
            fcv.setSayNpcName(null);
        }
    }


    @Override
    public void clickRightWindow(int i, UnifyShopSayUIEntity entity) {
        switch (i) {
            case 4:
                if (showFristIndex >= 7) {
                    showFristIndex -= 7;
                    setEndI(Math.min(monsters.size(), showFristIndex + 7));
                    resetUI();
                }
                break;
            case 5:
                if (endI < monsters.size()) {
                    showFristIndex += 7;
                    setEndI(Math.min(monsters.size(), showFristIndex + 7));
                    resetUI();
                }
                break;
            case 6:
                fcv.setOpenSayShop(false);
                FCRMaster.fcv.setOpenSay(false);
                FCRMaster.fcv.setSayNpcName(null);
                FCRMaster.fcv.setSayNpcTextNum(0);
                break;
        }
    }
}
